<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>																			
<%@ include file="/WEB-INF/view/jsp/base.jsp" %>																																			
<html lang="en">
<style>
.gradeA{
	cursor:pointer!important;
}
.widget-box tr td {
    text-align: left;
}
.mytable{
	border:1px solid #ddd;
    background-color: transparent;
    border-collapse: collapse;
    border-spacing: 0;
}
.mytable th{
   border:0px solid #ddd;
   padding:8px;
   text-align:center;
}
.mytable tr{
   border:1px solid #ddd;
}
.mytable td{
   padding:8px;
   background:#f6f6f6;
}

</style>
<body class="wysihtml5-supported">																																														
	<div id="content">																																										
		<div id="content-header"></div>																																						
		<div class="container-fluid">																																							
			<div class="">																																							
				<div style="font-size:15px;padding:15px 5px;">
					注册中心地址:&nbsp;<strong><span id="ibmsUrl" style="font-size:15px;">XXX.XXX.XXX.XXX:YYYYY</span></strong>
					&nbsp;&nbsp;&nbsp;&nbsp;
					状态:&nbsp;<strong><span id="ibmsStatus" style="font-size:15px;">启动|停止</span></strong>
				</div> 																																									
				<table id="sysRunManageTable" url=""  class="mytable">																	
					<thead>																																									
						<tr role="row">																																					
							<th class="ui-state-default" role="columnheader"  style="" name="sessionTypeName" primaryKey="true" >会话类型</th> 										
							<th class="ui-state-default" role="columnheader"  style="" name="localAdress">地址</th> 										
						</tr>																																								
					</thead>																																								
					<tbody id="sysParaTable-tbody" role="alert" aria-live="polite" aria-relevant="all">																										
					</tbody>																																								
				</table>																																									
			</div>																																												
		</div>																																													
	</div>																																														
</body>																																														
<script type="text/javascript">																																						
$(document).ready(function(){
	init();
	//1分钟刷新一次
	setInterval(load,60*1000);
})

function init(){
	getIbmsInfo("ibms.sh status \n");
}

function load(){
	$.ajax({
		url:"<%=path%>/sysRunManage/getSysRunManageList",
		data:{},
		type:"post",
		success:function(text){
			var data = text.data;
			var _data = data.data;
			var _ths = [];      //标题行
			var _primaryKey = [] ;  //唯一索引字段				
			$("#sysRunManageTable").find("thead tr th").each(function(){
				var $this = $(this) ;
				_ths.push($this.attr("name"));
				if($this.attr("primaryKey")=="true"){
					_primaryKey.push($this.attr("name")) ;
				}
			});
			var tbody = loadData(_data,_ths,_primaryKey);
			$("#sysRunManageTable").find("tbody").html(tbody);
		}
	});
}

function loadData(data,_ths,_primaryKey){
	var tbody = "";
	for(var i=0;i<data.length;i++){
		var tr = '<tr class="gradeA ">';
		for(var index in _ths){
							if(_ths[index]!="work-box"){
								var td_text = ((data[i][_ths[index]]==null)?"":data[i][_ths[index]]);
								tr+='<td class=" " >'+ td_text +'</td>';
							}else if(_ths[index]=="work-box"){
								tr+='<td class="center ">';
								tr+='<a href="#" onclick="edit($(this))"><span class="glyphicon glyphicon-pencil"></span></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" onclick="del($(this))"><span><span class="glyphicon glyphicon-remove"></span></span></a>';
								tr+='<form action="" method="post">';
								for(var key in _primaryKey){
									tr+='<input type="hidden" name="'+ _primaryKey[key] +'" value="'+ data[i][_primaryKey[key]] +'"/>';
								}
								tr+='</form>';
								tr+='</td>';
							}
						}
				 '</tr>' ;
		 tbody+=tr;	 
	}
	return tbody ;
}

function getIbmsInfo(cmd){
	$.ajax({
		url:"<%=path%>/sysRunManage/getIbmsInfo",
		data:{"cmd":cmd},
		type:"post",
		success:function(text){
			var data =  text.data ;
			$("#ibmsUrl").html(data.ibmsUrl);
			$("#ibmsStatus").html(data.ibmsStatus?"启动":"停止");
			//加载列表
			load();
		}		
	});
}


</script>																																												
</html>	    																																												

